package org.zsl.controller;

import com.alibaba.fastjson.JSON;
import org.zsl.model.User;
import org.zsl.service.UserService;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

public class UserListController extends HttpServlet {

    private UserService userService = new UserService();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        List<User> list = userService.getList();

        String json=  JSON.toJSONString(list);

        System.out.println(json);

        resp.getWriter().write(json);
    }
}
